package com.pearadmin.pro.common.tools.server.server;

import lombok.Setter;
import static com.pearadmin.pro.common.tools.core.MathUtil.div;
import static com.pearadmin.pro.common.tools.core.MathUtil.mul;

/**
 * 内存信息
 *
 * Author:  wangxiaozhe
 * CreateTime: 2021/04/01
 */
@SuppressWarnings("unused")
@Setter
public class Mem {
    /**
     * 内存总量
     */
    private double total;

    /**
     * 已用内存
     */
    private double used;

    /**
     * 剩余内存
     */
    private double free;

    public double getTotal()
    {
        return div(total, (1024 * 1024 * 1024), 2);
    }

    public double getUsed()
    {
        return div(used, (1024 * 1024 * 1024), 2);
    }

    public double getFree()
    {
        return div(free, (1024 * 1024 * 1024), 2);
    }

    public double getUsage()
    {
        return mul(div(used, total, 4), 100);
    }
}
